package blog.controller.articles;

import blog.service.CommentsService;
import blog.vo.Result;
import blog.vo.params.CommentParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/comments")
public class CommentsController {

    @Autowired
    private CommentsService commentsService;

    // 获取文章评论
    @GetMapping("/article/{id}")
    public Result comments(@PathVariable("id") Long articleId){

        return commentsService.commentsByArticleId(articleId);

    }

    // 创建评论
    @PostMapping("/create/change")
    public Result comment(@RequestBody CommentParam commentParam){

        return commentsService.comment(commentParam);

    }
}